bitkeeper revision 1.1713.3.15 (42b53156pSSLSNwQRl51kxkAtBPgTQ)
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Sun, 19 Jun 2005 08:48:22 +0000 (08:48 +0000)
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Sun, 19 Jun 2005 08:48:22 +0000 (08:48 +0000)
xsnode.py:
  fileno is a method now.
netif.py, blkif.py, XendDomainInfo.py:
  Cleanup interface to DB.
xs.c:
  Don't special case xs_fileno.
  Update comments.
Signed-off-by: Mike Wray <mike.wray@hp.com>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
tools/python/xen/lowlevel/xs/xs.c
tools/python/xen/xend/XendDomainInfo.py
tools/python/xen/xend/server/blkif.py
tools/python/xen/xend/server/netif.py
tools/python/xen/xend/xenstore/xsnode.py

index 1b86a03f655499a3751871411612b62793cf7cfa..726b83e8e1082200e7567ed8f9fc0d7ab70a3b37 100644 (file)
@@ -1,7 +1,7 @@
 /* 
   Python interface to the Xen Store Daemon.
   Copyright (C) 2005 Mike Wray Hewlett-Packard
-*/
* Python interface to the Xen Store Daemon.
* Copyright (C) 2005 Mike Wray Hewlett-Packard
+ */
 
 #include <Python.h>
 
@@ -196,6 +196,7 @@ static PyObject *xspy_mkdir(PyObject *self, PyObject *args, PyObject *kwds)
 #define xspy_rm_doc "\n"                       \
        "Remove a path.\n"                      \
        " path [string] : path to remove\n"     \
+       "\n"                                    \
        "Returns: [int] 0 on success.\n"        \
        "Raises RuntimeError on error.\n"       \
        "\n"
@@ -339,13 +340,14 @@ static PyObject *xspy_set_permissions(PyObject *self, PyObject *args,
     return val;
 }
 
-#define xspy_watch_doc "\n"                                    \
-       "Watch a path, get notifications when it changes.\n"    \
-       " path  [string] : xenstore path.\n"                    \
-       " token [string] : returned in watch notification\n"    \
-       "\n"                                                    \
-       "Returns: [int] 0 on success.\n"                        \
-       "Raises RuntimeError on error.\n"                       \
+#define xspy_watch_doc "\n"                                            \
+       "Watch a path, get notifications when it changes.\n"            \
+       " path     [string] : xenstore path.\n"                         \
+       " priority [int]    : watch priority (default 0).\n"            \
+       " token    [string] : returned in watch notification.\n"        \
+       "\n"                                                            \
+       "Returns: [int] 0 on success.\n"                                \
+       "Raises RuntimeError on error.\n"                               \
        "\n"
 
 static PyObject *xspy_watch(PyObject *self, PyObject *args, PyObject *kwds)
@@ -371,12 +373,14 @@ static PyObject *xspy_watch(PyObject *self, PyObject *args, PyObject *kwds)
     return val;
 }
 
-#define xspy_read_watch_doc "\n"               \
-       "Read a watch notification.\n"          \
-       " path [string]: xenstore path.\n"      \
-       "\n"                                    \
-       "Returns: [tuple] (path, token).\n"     \
-       "Raises RuntimeError on error.\n"       \
+#define xspy_read_watch_doc "\n"                               \
+       "Read a watch notification.\n"                          \
+       "The notification must be acknowledged by passing\n"    \
+       "the token to acknowledge_watch().\n"                   \
+       " path [string]: xenstore path.\n"                      \
+       "\n"                                                    \
+       "Returns: [tuple] (path, token).\n"                     \
+       "Raises RuntimeError on error.\n"                       \
        "\n"
 
 static PyObject *xspy_read_watch(PyObject *self, PyObject *args,
@@ -408,7 +412,7 @@ static PyObject *xspy_read_watch(PyObject *self, PyObject *args,
 
 #define xspy_acknowledge_watch_doc "\n"                                        \
        "Acknowledge a watch notification that has been read.\n"        \
-       " token [string] : returned in watch notification\n"            \
+       " token [string] : from the watch notification\n"               \
        "\n"                                                            \
        "Returns: [int] 0 on success.\n"                                \
        "Raises RuntimeError on error.\n"                               \
@@ -499,7 +503,7 @@ static PyObject *xspy_transaction_start(PyObject *self, PyObject *args,
 #define xspy_transaction_end_doc "\n"                                  \
        "End the current transaction.\n"                                \
        "Attempts to commit the transaction unless abort is true.\n"    \
-       " abort [int]: Abort flag..\n"                                  \
+       " abort [int]: abort flag (default 0).\n"                       \
        "\n"                                                            \
        "Returns: [int] 0 on success.\n"                                \
        "Raises RuntimeError on error.\n"                               \
@@ -556,10 +560,7 @@ static PyObject *xspy_introduce_domain(PyObject *self, PyObject *args,
     if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec,
                                      &dom, &page, &port, &path))
         goto exit;
-    printf("%s> dom=%u page=0x%08lx port=%u path=%s\n", __FUNCTION__, dom,
-          page, port, path);
     xsval = xs_introduce_domain(xh, dom, page, port, path);
-    printf("%s> xsval=%d\n", __FUNCTION__, xsval);
     val = pyvalue_int(xsval);
  exit:
     return val;
@@ -590,9 +591,7 @@ static PyObject *xspy_release_domain(PyObject *self, PyObject *args,
     if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec,
                                      &dom))
         goto exit;
-    printf("%s> dom=%u\n", __FUNCTION__, dom);
     xsval = xs_release_domain(xh, dom);
-    printf("%s> xsval=%d\n", __FUNCTION__, xsval);
     val = pyvalue_int(xsval);
  exit:
     return val;
@@ -651,6 +650,28 @@ static PyObject *xspy_shutdown(PyObject *self, PyObject *args, PyObject *kwds)
     return val;
 }
 
+#define xspy_fileno_doc "\n"                                   \
+       "Get the file descriptor of the xenstore socket.\n"     \
+       "Allows an xs object to be passed to select().\n"       \
+       "\n"                                                    \
+       "Returns: [int] file descriptor.\n"                     \
+       "\n"
+
+static PyObject *xspy_fileno(PyObject *self, PyObject *args, PyObject *kwds)
+{
+    static char *kwd_spec[] = { NULL };
+    static char *arg_spec = "";
+
+    struct xs_handle *xh = xshandle(self);
+    PyObject *val = NULL;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec))
+        goto exit;
+    val = PyInt_FromLong((xh ? xs_fileno(xh) : -1));
+ exit:
+    return val;
+}
+
 #define XSPY_METH(_name) {                     \
     .ml_name  = #_name,                                \
     .ml_meth  = (PyCFunction) xspy_ ## _name,  \
@@ -675,17 +696,14 @@ static PyMethodDef xshandle_methods[] = {
      XSPY_METH(release_domain),
      XSPY_METH(close),
      XSPY_METH(shutdown),
+     XSPY_METH(fileno),
      { /* Terminator. */ },
 };
 
 static PyObject *xshandle_getattr(PyObject *self, char *name)
 {
     PyObject *val = NULL;
-    if (strcmp(name, "fileno") == 0) {
-        struct xs_handle *xh = xshandle(self);
-        val = PyInt_FromLong((xh ? xs_fileno(xh) : -1));
-    } else
-        val = Py_FindMethod(xshandle_methods, self, name);
+    val = Py_FindMethod(xshandle_methods, self, name);
     return val;
 }
 
@@ -754,7 +772,7 @@ static PyMethodDef xs_methods[] = {
       "Raises RuntimeError on error.\n"
       "\n"
     },
-    { NULL, NULL, 0, NULL }
+    { /* Terminator. */ }
 };
 
 PyMODINIT_FUNC initxs (void)
index f14756015f3b530400de8f7f32ad270c0ed4399b..3b9c1cab795b2552ebea5ec378cfbcc10e197d1b 100644 (file)
@@ -511,7 +511,7 @@ class XendDomainInfo:
             self.configure_restart()
             self.construct_image()
             self.configure()
-            self.exportToDB()
+            self.exportToDB(save=True)
         except Exception, ex:
             # Catch errors, cleanup and re-raise.
             print 'Domain construction error:', ex
@@ -523,7 +523,7 @@ class XendDomainInfo:
     def register_domain(self):
         xd = get_component('xen.xend.XendDomain')
         xd._add_domain(self)
-        self.exportToDB()
+        self.exportToDB(save=True)
 
     def configure_cpus(self, config):
         try:
index 59932a3d8b112bd335361d75e5eda8ba2495524b..dac65c426b0fb89a870aab3cacb22d6cfc3ffd4f 100755 (executable)
@@ -50,6 +50,9 @@ class BlkifBackend:
     def getId(self):
         return self.id
 
+    def getEvtchn(self):
+        return self.evtchn
+
     def closeEvtchn(self):
         if self.evtchn:
             channel.eventChannelClose(self.evtchn)
@@ -198,7 +201,7 @@ class BlkDev(Dev):
         backend = self.getBackend()
         if backend and backend.evtchn:
             db = self.db.addChild("evtchn")
-            backend.evtchn.exportToDB(db, save=save)
+            backend.evtchn.saveToDB(db, save=save)
 
     def init(self, recreate=False, reboot=False):
         self.frontendDomain = self.getDomain()
index 8c60904ec51582e22aa0358406256429e1a2ead3..8d89f73605bc3f0d19304b2b24d861af8ecaffd7 100755 (executable)
@@ -95,7 +95,7 @@ class NetDev(Dev):
         Dev.exportToDB(self, save=save)
         if self.evtchn:
             db = self.db.addChild("evtchn")
-            self.evtchn.exportToDB(db, save=save)
+            self.evtchn.saveToDB(db, save=save)
 
     def init(self, recreate=False, reboot=False):
         self.destroyed = False
index fee14c395cbfd78783d83f0fe42663090bf95d07..94b264c3cf24a85c68c9f8cae604af8aa5252d42 100644 (file)
@@ -64,7 +64,7 @@ class Watcher:
 
     def fileno(self):
         if self.xs:
-            return self.xs.fileno
+            return self.xs.fileno()
         else:
             return -1